<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<input id="d1" value="2012-8-9" />
	</head>
	<body>
		<script>
			var s = d1.value;
			var firstIndex = s.indexOf("-");
			var secondIndex = s.indexOf("-",firstIndex+1);
			var y = s.substring(0,firstIndex);
			var m = s.substring(firstIndex+1,secondIndex);
			var d = s.substring(secondIndex+1);
			alert(y);
			alert(m);
			alert(d);
			
		</script>
	</body>
</html>
